import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets
// 引入国际化包
import i18n from './lang'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

// 自定义指令
import { imgError } from '@/directives'

import '@/icons' // icon
import '@/permission' // permission control

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
Vue.use(ElementUI, { i18n: (key, value) => i18n.t(key, value) })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.config.productionTip = false

Vue.directive('imgError', imgError)

// 定义全局的component
import Componment from './components'
Vue.use(Componment)

// 定义全局的filter
import * as formatDate from './filter'
// console.log(formatDate)
for (const key in formatDate) {
  Vue.filter(key, formatDate[key])
}
// import formatDate from '@/filter'
/* Vue.filter('formatDate', (oldValue) => {
  // const res = new Date(date)
  const date = new Date(oldValue)
  return date.toLocaleString()
}) */
// 混入
import newMixin from './mixin'
Vue.mixin(newMixin)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
